local M = {}

local Screen = require "Screen"
local Debug = require "Debug"

function M.sprn(text, color, duration)
    Screen.Print(text, color, duration)
end

function M.dprn(obj, prefix)
    Debug.Print(obj, prefix)
end

function M.DrawDebugPoint(Ctx, Pos, color, size, duration)
    Debug.DrawDebugPoint(Ctx, Pos, color, size, duration)
end

function M.SpawnAI(ctx, AIClass, SpawnOrigin, ActorLocation, PlayerCharacter)

    local SpawnLocation = UE.FVector()
    UE.UNavigationSystemV1.K2_GetRandomReachablePointInRadius(ctx, SpawnOrigin, SpawnLocation, 200)
    SpawnLocation.Z = SpawnLocation.Z + 100

    local SpawnRotation = nil
    local Target = nil

    if PlayerCharacter then
        Target = PlayerCharacter:K2_GetActorLocation()
    end

    if ActorLocation then
        Target = ActorLocation
    end

    if Target then
        SpawnRotation = UE.UKismetMathLibrary.FindLookAtRotation(SpawnLocation, Target)
    end

    UE.UAIBlueprintHelperLibrary.SpawnAIFromClass(ctx, AIClass, nil, SpawnLocation, SpawnRotation)
end


return M